#define  _CRT_SECURE_NO_WARNINGS

#include<stdio.h>
#include<string.h>


int main()
{
    char arr[3][101] = { 0 };
    int i = 0, flag = 1, len = 0, a[100] = { 0 }, b[100] = { 0 };
    for (i = 0; i < 3; i++)
    {
        gets(arr[i]);
    }
    len = strlen(arr[0]);
    for (i = 0; i < len; i++)
    {
        if (a[arr[0][i]] == 0 || a[arr[0][i]] == arr[1][i])
            a[arr[0][i]] = arr[1][i];
        else
            flag = 0;
    }
    for (i = 0; i < len; i++)
    {
        if (b[arr[1][i]] == 0 || b[arr[1][i]] == arr[0][i])
            b[arr[1][i]] = arr[0][i];
        else
            flag = 0;
    }
    for (i = 'A'; i <= 'Z'; i++)
    {
        if (a[i] == 0 || b[i] == 0)
            flag = 0;
    }
    if (flag == 1)
    {
        len = strlen(arr[2]);
        for (i = 0; i < len; i++)
        {
            arr[2][i] = a[arr[2][i]];
        }
        puts(arr[2]);
    }
    else
        printf("Failed\n");

    return 0;
}